package 集合.单列Collection.Set系列.TreeSet;

import java.util.Objects;

public class student implements Comparable<student>{
    private String name;
    private int age;

    public student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(student o) {
        //指定排序的规则
        //只看年龄
        return this.getAge()-o.getAge();
        /*this是要添加的元素
        o是红黑树已经存在的元素
        返回值
        负数，存左边
        正数，存右边
        0，认为已经存在该元素，舍弃
        */
    }
}
